<template>
  <el-tabs type="card" v-model="activeName">
    <el-tab-pane v-if="showReleasedTabs" label="流程图发布" name="first">
      <ReleasedFlowChart ref="released" :detailStatus="this.showDetail"></ReleasedFlowChart>
    </el-tab-pane>
    <el-tab-pane v-if="showPushTabs" label="流程图推送" name="second">
      <Push ref="push"></Push>
    </el-tab-pane>
  </el-tabs>
</template>

<script>
import ReleasedFlowChart from "./ReleasedFlowChart";
import Push from "./Push";

export default {
  name: "FlowChartManage",
  components: {
    Push,
    ReleasedFlowChart
  },
  data() {
    return {
      activeName: 'first',
      showDetail: '',
      showPushTabs: false,
      showReleasedTabs: false
    }
  },
  activated() {
    if (this.$route.meta.isUseCache) {
      this.$refs.released.getTableData();
      return
    }

    if (this.$store.state.user.userName === 'admin') {
      this.showPushTabs = true
      this.showReleasedTabs = true
      this.showDetail = 'false'
      return
    }
    //角色Id等于管理员角色
    for (let i = 0; i < this.$store.state.user.roleIds.length; i++) {
      if (this.$store.state.user.roleIds[i] === '1455781731549327361') {
        this.showPushTabs = true
        this.showReleasedTabs = true
        this.showDetail = 'false'
        return;
      }
    }
    UTIL.findTreeNode(this.$store.state.menuList, item => {
      if (item.id === this.$store.state.activeId) {
        this.showPushTabs = true
        this.showReleasedTabs = true
        if (item.editButton || item.detailButton) {
          this.showPushTabs = false
          if (item.editButton && item.detailButton) {
            this.showDetail = 'false'
          } else {
            if (item.detailButton) {
              this.showDetail = "true"
            }
          }
        }
        if (item.pushButton && item.editButton) {
          this.showReleasedTabs = true
          this.showPushTabs = true
          this.activeName = 'first'
          this.showDetail = 'false'
        } else {
          if (item.pushButton && item.detailButton) {
            this.showReleasedTabs = true
            this.showPushTabs = true
            this.activeName = 'first'
            this.showDetail = 'true'
          } else {
            if (item.pushButton) {
              this.showReleasedTabs = false
              this.showPushTabs = true
              this.activeName = 'second'
            }
          }
        }
      }
    })
  }

}
</script>

<style scoped>

</style>
